package cc.ycws.core.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 单元楼表
 * </p>
 *
 * @author tutu
 * @since 2018-05-22
 */
@TableName("mdm_building")
public class MdmBuilding implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 单元楼编号
     */
    @TableField("building_no")
    private String buildingNo;

    /**
     * 单元楼名称
     */
    @TableField("building_name")
    private String buildingName;

    /**
     * 小区编号
     */
    @TableField("community_no")
    private String communityNo;

    /**
     * 建档人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String creator;

    /**
     * 建档时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time", fill = FieldFill.INSERT_UPDATE)
    private Date createTime;

    /**
     * 修改人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String modifier;

    /**
     * 修改时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
    private Date modifyTime;

    /**
     * 备注
     */
    private String remarks;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBuildingNo() {
        return buildingNo;
    }

    public void setBuildingNo(String buildingNo) {
        this.buildingNo = buildingNo;
    }

    public String getBuildingName() {
        return buildingName;
    }

    public void setBuildingName(String buildingName) {
        this.buildingName = buildingName;
    }

    public String getCommunityNo() {
        return communityNo;
    }

    public void setCommunityNo(String communityNo) {
        this.communityNo = communityNo;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    @Override
    public String toString() {
        return "MdmBuilding{" +
                "id=" + id +
                ", buildingNo=" + buildingNo +
                ", buildingName=" + buildingName +
                ", communityNo=" + communityNo +
                ", creator=" + creator +
                ", createTime=" + createTime +
                ", modifier=" + modifier +
                ", modifyTime=" + modifyTime +
                ", remarks=" + remarks +
                "}";
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof MdmBuilding == false) {
            return false;
        }
        MdmBuilding obj1 = (MdmBuilding) obj;
        return this.getBuildingName().equals(obj1.getBuildingName()) &&
                this.getCommunityNo().equals(obj1.getCommunityNo());
    }

    @Override
    public int hashCode() {
        int n = 31;
        return n;
    }

    public static void main(String[] args) {
        MdmBuilding mdmBuilding = new MdmBuilding();
        mdmBuilding.setCommunityNo("1");
        mdmBuilding.setBuildingName("1");
        MdmBuilding mdmBuilding1 = new MdmBuilding();
        mdmBuilding1.setCommunityNo("1");
        mdmBuilding1.setBuildingName("1");
        List<MdmBuilding> list = new ArrayList<>();
        list.add(mdmBuilding1);        list.add(mdmBuilding);
        List<MdmBuilding> collect = list.stream().distinct().collect(Collectors.toList());
        System.out.println(collect);

    }
}
